from openai import OpenAI

from deepseek.DeepSeekModel import DeepSeekModel

# DeepSeek的对话工具类
class DeepSeekAi:

    def __init__(self, api_key: str,model: DeepSeekModel):
        # 出于与 OpenAI 兼容考虑，您也可以将 base_url 设置为 https://api.deepseek.com/v1 来使用，但注意，此处 v1 与模型版本无关
        self.client = OpenAI(api_key=api_key, base_url="https://api.deepseek.com")
        # deepseek r1模型
        self.model = model.value

    # 持续聊天
    def chat(self, messages: list):
        # messages = [{"role": "user", "content": "What's the highest mountain in the world?"}]
        response = self.client.chat.completions.create(
            model=self.model,
            messages=messages
        )
        print(response)
        return response.choices[0].message.content


deepSeekAi = DeepSeekAi("sk-063f950b50fb4a08b9497e9cf721f7ab", DeepSeekModel.DeepSeek_V3)

if __name__ == "__main__":
    print(deepSeekAi.chat([{"role": "user", "content": "hello world,请用中文回复"}]))